﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace SellAndBuy.Application.Query.DTOs
{
    /// <summary>
    /// Ad DTO
    /// </summary>
    public class AdDTO
    {
        private readonly IList<PictureInfoDTO> _pictures = new List<PictureInfoDTO>();

        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; }

        /// <summary>
        /// Customer
        /// </summary>
        public string Owner { get; set; }

        /// <summary>
        /// Title
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// Description
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// Price
        /// </summary>
        public decimal Price { get; set; }

        /// <summary>
        /// Creation date
        /// </summary>
        public DateTime CreationDate { get; set; }

        /// <summary>
        /// Pictures
        /// </summary>
        public virtual IList<PictureInfoDTO> Pictures
        {
            get { return _pictures; }
        }

        /// <summary>
        /// Get the main picture
        /// </summary>
        public PictureInfoDTO MainPicture
        {
            get { return Pictures.FirstOrDefault(picture => picture.IsMain); }
        }
    }
}